/*
 * @Author: Superficial
 * @Date: 2021-10-25 20:30:15
 * @LastEditTime: 2021-10-25 20:36:47
 * @Description: 日期处理
 */

import dayjs from 'dayjs'

/** dayjs -> 秒时间戳 */
export const dayjsToTimestamp = (dayjs: dayjs.Dayjs) => dayjs.unix()

/** 秒时间戳 -> dayjs */
export const timestampToDayjs = (timestamp: number) => dayjs.unix(timestamp)

/** 时间戳 -> YMD */
export const timestampToYMD = (timestamp: number) => {
  return dayjs(timestamp)?.format('YYYY-MM-DD HH:mm:ss')
}

/** 时间字符串 -> YMD */
export const stringToYMD = (timestamp: string) => {
  return dayjs(timestamp)?.format('YYYY-MM-DD HH:mm:ss')
}
